<?php
namespace app\api\model;
use traits\model\SoftDelete;

class User extends Base
{
    use SoftDelete;
    // 设置当前模型的数据库连接


    /**
     * 获取会员组别  1 免费会员 2 会员 3  4
     * @param $user_id
     * @return int|mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getUserType($user_id){
        //获取会员组别
        $userModel =  (new User())->where([['id','eq',$user_id]])->find();
        //防止会员过期
        if($userModel["user_type"] > 1 &&$userModel["vip_time"]>time()){
            return $userModel["user_type"];
        }
        return 1;
    }
}